#
# Copyright (c) 2007 Thomas Fors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

ACRCAL  =  AcrCalibrator.jsx
ALIGN   =  AcrCalibrator-AlignmentCheck

MAIN    =  Main.js
ALIGNMAIN = AlignmentCheck.js

SOURCES += Acr.js
SOURCES += ColorChecker.js
SOURCES += Simplex.js
SOURCES += Display.js
SOURCES += ProPhotoRGBColor.js
SOURCES += Matrix3x3.js
SOURCES += Vector1x3.js

PHOTOSHOP ?= /Applications/Adobe Photoshop CS2

all:
	./checkSubVersion.pl
	# Test if script gets installed somewhere else
	if [ -e photoshopVersion ]; then export PHOTOSHOP="`./getPsVersion.pl`"; fi; make install
clean:
	rm -f build/$(ACRCAL)

install: $(ACRCAL) $(ALIGN).jsx

$(ACRCAL): build/$(ACRCAL) getPsVersion.pl photoshopVersion
	rm -f $(ACRCAL)
	ln -s "$(PHOTOSHOP)/Presets/Scripts/$(ACRCAL)" $(ACRCAL)
	cp build/$(ACRCAL) $(ACRCAL)

align: $(ALIGN).jsx

$(ALIGN).jsx: build/$(ALIGN).jsx getPsVersion.pl photoshopVersion
	rm -f $(ALIGN).jsx
	ln -s "$(PHOTOSHOP)/Presets/Scripts/$(ALIGN).jsx" $(ALIGN).jsx
	cp build/$(ALIGN).jsx $(ALIGN).jsx

build/$(ACRCAL): $(MAIN) $(SOURCES) Makefile substFiles.pl version svnversion
	-chmod 755 build/$(ACRCAL)
	./substFiles.pl $(MAIN) $(SOURCES) $@
	chmod 555 build/$(ACRCAL)

build/$(ALIGN).jsx: $(ALIGNMAIN) $(SOURCES) Makefile substFiles.pl version svnversion
	chmod 755 build/$(ALIGN).jsx
	./substFiles.pl $(ALIGNMAIN) $(SOURCES) $@
	chmod 555 build/$(ALIGN).jsx

tag:
	./tagBuild.pl

tools: tools/$(ALIGN).zip

tools/$(ALIGN).zip: build/$(ALIGN).jsx
	cp build/$(ALIGN).jsx tools/$(ALIGN).jsx
	rm -f tools/$(ALIGN).zip
	cd tools; zip $(ALIGN).zip $(ALIGN).jsx
	rm -f tools/$(ALIGN).jsx

